@extends('admin.layouts.admin')

@section('content')
	<h1>Documents</h1>
	<div class="panel panel-info">
		<div class="panel-heading">
			<h3 class="panel-title">
				@foreach($breadcrumb as $id => $name)
					<a href="{{ URL::route('admin-docs', $id) }}">{{ $name }}</a> /
				@endforeach
			</h3>
		</div>
		<div class="panel-body">
			<a href="{{ URL::route('admin-add-docs', $id) }}" class="btn btn-primary">
				<span class="glyphicon glyphicon-cloud-upload"></span>
				Uploader un fichier
			</a>
			<a href="{{ URL::route('admin-add-folder', $id) }}" class="btn btn-primary">
				<span class="glyphicon glyphicon-plus-sign"></span>
				Créer un dossier
			</a>

			@if($documents->count() > 0)
				<div class="table-responsive">
					<table class="table table-striped table-hover">
						<thead>
								<th></th>
								<th>Nom</th>
								<th>Auteur</th>
								<th>Date</th>
								<th>Take action !</th>
						</thead>
						<tbody>
							@foreach($documents as $document)
								<tr>
									<td>
										@if($document->type == 1)
											<span class="glyphicon glyphicon-folder-open"></span>
										@else
											<span class="glyphicon glyphicon-file"></span>
										@endif
									</td>
									<td>
										@if($document->type == 1)
											<a href="{{ URL::route('admin-docs', $document->id) }}">{{ $document->filename }}</a>
										@else
											<a target="_blank" href="{{ asset($document->path) }}">{{ $document->filename }}</a>
											<span class="glyphicon glyphicon-new-window"></span>
										@endif
									</td>
									<td>{{ $document->user->username }}</td>
									<td>{{ $document->date }}</td>
									<td>
										@if($document->type == 1)
											<a href="" class="btn btn-danger">
												<span class="glyphicon glyphicon-remove"></span>
												Supprimer
											</a>
										@else
											<a data-name="{{ $document->filename }}" href="{{ URL::route('admin-delete-file', $document->id) }}" class="btn btn-danger delete-file">
												<span class="glyphicon glyphicon-remove"></span>
												Supprimer
											</a>
										@endif
									</td>
								</tr>
							@endforeach
						</tbody>
					</table>
				</div>
			@else
				<br/><br/>
				<div class="alert alert-success">
		        	Aucun documents !
		      	</div>
			@endif
		</div>
	</div>
@stop